import React, { useEffect, useLayoutEffect, useRef } from 'react'

export default function LayoutCom() {
  let ref = useRef();

  // useEffect(() => {
  //   // console.log('effect run')
  //   ref.current.style.width = '600px';
  // })

  //使用 useLayoutEffect
  useLayoutEffect(() => {
    // console.log('layout effect run')
    ref.current.style.width = '600px';
  });

  return (
    <div ref={ref} style={{width: 400, height: 200, background: '#aef'}}>
      
    </div>
  )
}
